﻿@*
    For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    Layout = "~/Areas/SysAdmin/Views/Shared/_Layout.cshtml";
}
@section styles{
    <link href="/css/plugins/jqgrid/ui.jqgridffe4.css?0820" rel="stylesheet">
    <style>
        /* Additional style to fix warning dialog position */

        #alertmod_table_list_2 {
            top: 900px !important;
        }
    </style>
}
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>文章列表</h5>
                </div>
                <div class="ibox-content">

                    <h4 class="m-t"><a href="/sysadmin/Article/Add">添加文章</a></h4>

  <div class="form-group">
      <div class="input-group">
                                        <input type="text" class="form-control"> <span class="input-group-btn"> <button type="button" class="btn btn-primary">搜索
                                        </button> </span>
                                    </div>
  </div>
   <div class="hr-line-dashed"></div>
                    <div class="jqGrid_wrapper">
                        <table id="jqGrid"></table>
                        <div id="pagerlist"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script src="/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="/js/plugins/jqgrid/i18n/grid.locale-cnffe4.js?0820"></script>
    <script src="/js/plugins/jqgrid/jquery.jqGrid.minffe4.js?0820"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script type="text/javascript">


        $(document).ready(function () {
            $.jgrid.defaults.styleUI = "Bootstrap";
 jQuery("#jqGrid").jqGrid(
      {
        url : '/sysadmin/article/indexdata',
        datatype : "json",
        colNames: ["序号", "标题", "分类", "排序", "添加时间", "操作", ],
        colModel: [
                    { name: "id", index: "id", editable: false, width: 60, sorttype: "int", search: true },
                    { name: "title", index: "title", editable: false, width: 100 },
                    { name: "categoryTitle", index: "categoryTitle", editable: false, width: 90 },
                    { name: "sortId", index: "sortId", editable: true, width: 80, align: "right"},
                    { name: "addTime", index: "addTime", editable: false, width: 80, align: "right", sorttype: "date", formatter: "date" },
                    { name: "id", index: "id", editable: false, width: 80, align: "right", formatter: formatOperation }],                   
        cellEdit: true,
        afterSaveCell : function(rowid,name,val,iRow,iCol) { //保存数据后操作    
                     //  var sortidval = jQuery("#jqGrid").jqGrid('getCell',rowid,iCol);   
                      },
        rowNum : 15,
        rowList : [ 10, 15, 20 ],
        pager : '#pagerlist',
        width: 780,
        height: 560,

     cellurl:"/sysadmin/article/updateSortId"//单元格编辑url
     // editurl : "/sysadmin/article/updateSortId",
      }).navGrid("#pagerlist", {edit : false,add : false,del : false});
     var width = $(".jqGrid_wrapper").width(); $("#jqGrid").setGridWidth(width) 

            function formatOperation(cellValue, options, rowObject) {
                return "<a href='/sysadmin/Article/edit/" + cellValue + "'>编辑</a>";
            };

            function formatTitle(cellValue, options, rowObject) {
                return cellValue.substring(0, 50) + "...";
            };

            function formatLink(cellValue, options, rowObject) {
                return "<a href='" + cellValue + "'>" + cellValue.substring(0, 25) + "..." + "</a>";
            };

            $("#jqGrid").setSelection(4, true);
            $('#jqGrid').navGrid('#pagerlist',
                   // the buttons to appear on the toolbar of the grid
                   { edit: false, add: false, del: true, search: false, refresh: false, view: false, position: "left", cloneToTop: false },
                   // options for the Edit Dialog
                   {

                       errorTextFormat: function (data) {
                           return 'Error: ' + data.responseText
                       }
                   },
                   // options for the Add Dialog
                   {

                       errorTextFormat: function (data) {
                           return 'Error: ' + data.responseText
                       }
                   },
                   // options for the Delete Dailog
                   {
                       url: "/sysadmin/Article/del",
                       errorTextFormat: function (data) {
                           return 'Error: ' + data.responseText
                       }
                   });

            var width = $(".jqGrid_wrapper").width();
            $("#jqGrid").setGridWidth(width);
            $(window).bind("resize", function () { var width = $(".jqGrid_wrapper").width(); $("#jqGrid").setGridWidth(width) })

        });

    </script>


}
